package com.leyou.item.service;

import com.leyou.common.Exception.LyException;
import com.leyou.item.entity.Item;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ItemService {

    int id = 0;

    public Item saveItem(Item item){

        if (item.getName() == null){

            throw new LyException("名称不能为空",400);
        }

        if (item.getPrice() == null){
            throw new LyException("价格不能为空",400);
        }

        item.setId(id++);
        return item;
    }

}
